using System;
using System.Data;
using DotNetNuke.Framework;

using DesertedRoadStudios.BlogNetNuke.Common;

namespace DesertedRoadStudios.BlogNetNuke.Components
{
    public abstract class DataProvider
    {

        #region common methods

        /// <summary>
        /// var that is returned in the this singleton
        /// pattern
        /// </summary>
        private static DataProvider instance = null;

        /// <summary>
        /// private static cstor that is used to init an
        /// instance of this class as a singleton
        /// </summary>
        static DataProvider()
        {
            instance = (DataProvider)Reflection.CreateObject("data", "DesertedRoadStudios.BlogNetNuke.Components", "");
        }

        /// <summary>
        /// Exposes the singleton object used to access the database with
        /// the conrete dataprovider
        /// </summary>
        /// <returns></returns>
        public static DataProvider Instance()
        {
            return instance;
        }

        #endregion

        #region Abstract methods
        // BNNDefault.aspx
        public abstract IDataReader GetBlogTabInfo(int portalID, int moduleID, string tabPath);
        public abstract IDataReader GetAllBlogTabInfo(int portalID);

        // Module Page_Init
        public abstract int UpdateTabID(int portalID, int moduleID, int tabID);

        // Module Host Settings
        public abstract IDataReader GetFriendlyURLs();
        public abstract void InsertFriendlyURL(string path);
        public abstract void DeleteFriendlyURL(int pathID);
        public abstract string GetSetting(int portalID, int moduleID, string setting);
        public abstract IDataReader GetSettings(int portalID, int moduleID);
        public abstract void SetSetting(int portalID, int moduleID, string setting, string value);
        public abstract void ClearSettings(int portalID, int moduleID);

        // Posts
        public abstract string GetTabPath(int portalID, int tabID, int moduleID);
        public abstract IDataReader GetAllPosts(int portalID, int moduleID, int tabID);
        public abstract IDataReader GetAllPublishedPosts(int portalID, int moduleID, int tabID);
        public abstract IDataReader GetAllPostsUnderReview(int portalID, int moduleID, int tabID);
        public abstract IDataReader GetAllPostDrafts(int portalID, int moduleID, int tabID);
        public abstract IDataReader GetAllDeletedPosts(int portalID, int moduleID, int tabID);
        public abstract IDataReader GetPostByDateSlug(int portalID, int moduleID, DateTime publishedDate, string slug);
        public abstract IDataReader GetPostByPostID(int portalID, int moduleID, Guid postID);
        public abstract IDataReader GetPostByPostPath(int portalID, int moduleID, string postPath);
        public abstract IDataReader GetAllPostsByDate(int portalID, int moduleID, int tabID, DateTime publishedDate);
        public abstract IDataReader GetAllPostsByDateRange(int portalID, int moduleID, int tabID, DateTime beginDate, DateTime endDate);
        public abstract object ValidatePostTitle(int portalID, int moduleID, int tabID, string slug);
        public abstract void InsertPost(PostInfo post);
        public abstract void UpdatePost(PostInfo post);
        public abstract void SetPostStatus(int portalID, int moduleID, Guid postID, PostStatus status);
        public abstract IDataReader GetAllPostsForCategory(int portalID, int moduleID, string slug);
        public abstract IDataReader GetAllPostsForTag(int portalID, int moduleID, string slug);

        // Comments
        public abstract IDataReader GetAllCommentsForPost(int portalID, int moduleID, Guid postID);
        public abstract void AddCommentToPost(CommentInfo comment);
        public abstract void ApproveComment(Guid commentID, int portalID, int moduleID, Guid postID);
        public abstract void UnApproveComment(Guid commentID, int portalID, int moduleID, Guid postID);
        public abstract void DeleteComment(Guid commentID, int portalID, int moduleID, Guid postID);
        public abstract void UnDeleteComment(Guid commentID, int portalID, int moduleID, Guid postID);

        // Categories
        public abstract IDataReader GetAllCategories(int portalID, int moduleID);
        public abstract int AddCategory(CategoryInfo category);
        public abstract void UpdateCategory(CategoryInfo category);
        public abstract void AddCategoryToPost(int categoryID, Guid postID);
        public abstract IDataReader GetAllCategoriesForPost(Guid postID);
        public abstract IDataReader GetAllCategoriesForPosts(int portalID, int moduleID);
        public abstract void DeleteAllCategoriesForPost(Guid postID);

        // Tags
        public abstract int AddTag(TagInfo category);
        public abstract void AddTagToPost(int tagID, Guid postID);
        public abstract int GetTagID(string tag, int portalID, int moduleID);
        public abstract IDataReader GetAllTags(int portalID, int moduleID);
        public abstract IDataReader GetAllTagsForPost(Guid postID);
        public abstract IDataReader GetAllTagsForPosts(int portalID, int moduleID);
        public abstract void DeleteAllTagsForPost(Guid postID);

        // TinyURLs
        public abstract void AddTinyUrl(string domainName, int moduleID, bool logRedirects);
        public abstract void AddTinyUrlRedirect(int tinyURLID, string code, Guid postID);
        public abstract void AddTinyUrlLog();
        public abstract void DeleteTinyUrlLog(int redirectID);
        public abstract IDataReader GetTinyUrlLog(int redirectID);
        public abstract IDataReader GetTinyUrl(Guid postID);
        public abstract IDataReader GetTinyUrlDomain(int moduleID);
        public abstract IDataReader GetPostForTinyUrl(string domain, string code);
        public abstract IDataReader GetTinyUrlDomains();


        #endregion

    }

}
